$(function() {
	/*激活按钮*/
	$('.form input').each(function(){
		$(this).bind('input propertychange',function(){
			var bool = $('.form input').eq(0).val() != '' && $('.form input').eq(1).val() != '' && $('.form input').eq(2).val() != '' && $('.form input').eq(3).val() != '';
			if(bool){
				$('button').removeClass('disabled').removeAttr('disabled');
			}else{
				$('button').addClass('disabled').attr('disabled','true');
			};
		});
	});
	
	$('.form button').click(function(){
		var password = '';
		if($('.password1').val() == $('.password2').val()){
			password = $('.password2').val();
		}else{
			alert('两次输入密码不一致，请重新输入');
			$('.password1,.password2').val('');
			$('.password1').focus();
			return false;
		};
		$.ajax({
			type:'get',
			url:url() + '/wxuser/setSecurityInfo',
			data:{
				payPassword:password,
				question:$('.question').val(),
				answer:$('.answer').val()
			},
			dataType:'json',
			success:function(rel,sta,xhr){
				var sessionstatus = xhr.getResponseHeader('redirectStatus');
				
				if(sessionstatus == '302'){
					window.location.href = url() + '/wxuser/goCompleteInfo';
					return false;
				};
				var rel_obj = JSON.parse(rel.result);
				//console.log(rel_obj)
				if(rel.code == 0 && rel_obj.status == 0){
					window.location.href = url() + '/htm/cash.html';
				}else{
					alert(rel_obj.message)
				}
			},
			error:function(){
				console.log('error');
			}
		})	
	})
			
})